﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace P2PTransmit.ViewModal.Command
{
    public class SendFile:ICommandBase
    {
        public override bool CanExecute(object parameter)
        {
            if(parameter is P2PTransmitViewModal v)
            {
                if ( v.CurrentSelected == null || v.Task.Count == 0)
                    return false;
                if ( v.CurrentSelected == null )
                    v.CurrentSelected = v.Task[0];
                return true;
            }
            return false;
        }

        public override void Execute(object parameter)
        {
            var v = parameter as P2PTransmitViewModal;
            v.TransmitService.SendRequest( v.CurrentSelected, v.SelectedConnection.MachineMacAddress );
        }
    }
}
